Component({
	properties: {
		current: Number, // 组件默认选中项
		backgroundColor: {
			type: String,
			value: "#333"
		},
		color: {
			type: String,
			value: "#9e9e9e"
		},
		selectedColor: {
			type: String,
			value: "#ffffff"
		},
		backgroundImg: {
			type: Boolean,
			value: true
		}
	},
	lifetimes: {
		ready: function () {
			// 获取组件传参，并更新菜单选中项
			this.setData({
				selected: this.properties.current,
				fontColor: this.properties.color,
				selectedFontColor: this.properties.selectedColor,
			})
		}
	},
	data: {
		selected: 0,
		fontColor: "#9e9e9e",
		selectedFontColor: "#ffffff",
		list: [{
			pagePath: "/pages/index/index",
			text: "首页"
		}, {
			pagePath: "/pages/meal/meal",
			text: "点餐"
		}, {
			pagePath: "/pages/projectList/projectList",
			text: "项目"
		}, {
			pagePath: "/pages/ledger/ledger",
			text: "记账"
		}, {
			pagePath: "/pages/my/my",
			text: "我的"
		}]
	},
	methods: {
		switchTab(e) {
			const data = e.currentTarget.dataset
			const url = data.path
			wx.switchTab({
				url: url,
				success: function (res) {},
				fail: function (err) {
					console.log(err)
				}
			})
		}
	}
})